package com.ccdt.tv.roundprogram.view.custom;

import android.view.View;
import android.widget.AdapterView;
import android.widget.BaseAdapter;

/**
 * 简化OnItemSelectedListener逻辑
 */
public abstract class MyOnItemSelectedListener implements AdapterView.OnItemSelectedListener {

    public abstract void onItemSelected(BaseAdapter adapter, int position, long id);

    @Override
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        BaseAdapter adapter = null;
        if (parent.getAdapter() instanceof BaseAdapter) {
            adapter = (BaseAdapter) parent.getAdapter();
        }
        onItemSelected(adapter, position, id);
    }

    @Override
    public void onNothingSelected(AdapterView<?> parent) {

    }
}
